package com.itheima.controller;

import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author 黑马程序员
 * @Company http://www.ithiema.com1
 * @Version 1.0
 */
@RestController
@RequestMapping("/test")
public class TestController {
    /**
     * @PreAuthorize(): 在控制器方法执行之前做权限判断
     *  @PostAuthorize(): 在控制器方法执行之后做权限判断
     * @return
     */
    @RequestMapping("/add")
    @PreAuthorize("hasAuthority('add')")
    public String  add(){
        System.out.println("添加");
        return "add";
    }


    @RequestMapping("/delete")
    @PreAuthorize("hasAuthority('delete')")
    public String  delete(){
        System.out.println("删除");
        return "delete";
    }


}
